/*
 *
 * Copyright (C) 2012 Walter Lütgenau
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package offset.nodes.client.veditor.view.image;

import java.net.MalformedURLException;
import java.net.URL;
import offset.nodes.client.model.ServerModel;
import offset.nodes.client.editor.Editor;
import offset.nodes.client.editor.view.image.ImageDialog;
import offset.nodes.client.veditor.VirtualEditor;

/**
 *
 * @author  Walter Lütgenau
 */
public class VirtualImageDialog extends ImageDialog {
    
    public static final int TYPE_REPOSITORY = 0;
    public static final int TYPE_DATA = 2;

    private offset.nodes.client.veditor.view.image.DataImagePanel dataImagePanel;


    /** 
     * Creates a new HyperlinkDialog
     * 
     * @param editor A reference to the editor
     */
    public VirtualImageDialog(Editor editor) throws Exception {
        super(editor);
    }

    public String getPropertyName() {
        return dataImagePanel.getPropertyName();
    }

    protected void initDataImagePanel() {
        getTabbedPane().setEnabledAt(TYPE_DATA, true);

        dataImagePanel.init(getEditor(), this);
    }

    public void init(int mode) throws Exception {
        getTabbedPane().setEnabledAt(TYPE_REPOSITORY, false);
        getTabbedPane().setEnabledAt(TYPE_DATA, false);
        getTabbedPane().setEnabledAt(TYPE_LOCAL, false);

        switch (mode) {
            case Editor.MODE_LOCAL_PAGE_EDITOR:
            case Editor.MODE_PAGE_EDITOR:
                getTabbedPane().setSelectedIndex(TYPE_REPOSITORY);
                initRepositoryImagePanel();
                initLocalImagePanel();
                break;

            case VirtualEditor.MODE_TEMPLATE_EDITOR:
            case VirtualEditor.MODE_VIRTUAL_PAGE_EDITOR:
                getTabbedPane().setSelectedIndex(TYPE_DATA);
                initDataImagePanel();
                initRepositoryImagePanel();
                break;

            case VirtualEditor.MODE_VIRTUAL_PAGE_DATA_EDITOR:
                break;
        }
    }

    protected void initializeComponents() {
        super.initializeComponents();
        

        dataImagePanel = new offset.nodes.client.veditor.view.image.DataImagePanel();

        getTabbedPane().addTab(java.util.ResourceBundle.getBundle("offset/nodes/client/veditor/view/resources/EditorBundle").getString("Image.Data.title"), dataImagePanel); // NOI18N
    }

}
